# -*- ecoding: utf-8 -*-
# @ModuleName: file_operator
# @Author: Kandy
# @Time: 2024-04-30 10:42
from _lock.file_lock import FileLock
import time

class FileRD(object):

    def __init__(self):

        pass

    @classmethod
    def read_file(self,filename) -> str:
        with FileLock(filename, timeout=0.1) as lock:
            ff = open(filename, 'r')
            line = ff.readline()
            print(line)
            return line

    @classmethod
    def write_file(self,filename,msg):
        with FileLock(filename, timeout=0.1) as lock:
            ff = open(filename, 'w')
            ff.write(msg)
            print(f"写入成功...{msg}")

